<?php
function cbo_lengthofstay($value='') {
	global $lang, $arr_lengthofstay_v, $arr_lengthofstay_e;
	if($lang=='v')
		$arr_lengthofstay = $arr_lengthofstay_v;
	else
		$arr_lengthofstay = $arr_lengthofstay_e;
	
	foreach($arr_lengthofstay as $k => $v){
		if($arr_lengthofstay[$k]==$value){
			$select=" selected='selected'";
		}else{
			$select="";
		}
		$cbo_lengthofstay.="<option value='".$arr_lengthofstay[$k]."' ".$select.">".$arr_lengthofstay[$k]."</option>";
	}

	return $cbo_lengthofstay;
}
///
function cbo_city($country_id, $value='') {
	global $lang;
	
	$cond = " AND lang='".$lang."'";
	
	if($country_id) $cond .= " AND country_id='".$country_id."'";
	
	$sql="SELECT city_id, city_name FROM ".pre_table."city WHERE 1=1 ".$cond."";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)){
		while($row=mysql_fetch_assoc($rs)){
			if($row['city_id']=="$value"){
				$select=" selected='selected'";
			}else {
				$select="";
			}
			$cbo_cat.="<option value='".$row['city_id']."' ".$select.">".$row['city_name']."</option>";
		}
	}
	return $cbo_cat;
}
///
function getCountryID($country_code){
	global $lang;
	$sql = "SELECT country_id, country_name, country_code 
				FROM ".pre_table."country WHERE country_code='".$country_code."' AND lang='".$lang."'";
	$rs = recordset($sql);
	if($rs['country_id']>0){
		$country_array = array($rs['country_id'], $rs['country_name'], $rs['country_code']);
		return $country_array;
	}
}
///
function cbo_star($value='') {
	$arr_star = array("1", "2", "3", "4", "5");
	
	foreach($arr_star as $k => $v){
		if($v==$value){
			$select=" selected='selected'";
		}else{
			$select="";
		}
		$cbo_star.="<option value='".$v."' ".$select.">".$v."</option>";
	}

	return $cbo_star;
}
///
function getTitle($category_id){
	$sql="SELECT parent_id, category_id, category_name".lang." AS category_name FROM ".pre_table."category WHERE category_id='".$category_id."'";
	$rs=recordset($sql);
	$parent_id=$rs['parent_id'];
	
	$child_name = $rs['category_name'];
	if($parent_id!=0){
		$sql3="SELECT category_id, category_name".lang." AS category_name FROM category WHERE category_id='".$parent_id."'";
		$rs3=recordset($sql3);
		$parent_name= ' - '.$rs3['category_name'].'';		
	}
	
	$path = $parent_name." - ".$child_name;

	return $path;
}

function counter(){
	global $host, $dbuser, $dbpwd, $dbname;
	include "littleCounter.php";
	
	$counter = new littleCounter;
	$counter->dbhost = $host;
	$counter->dbuser = $dbuser;
	$counter->dbpwd = $dbpwd;
	$counter->dbdatabase = $dbname;
	$counter->dbtable = "counter";
	$counter->onlinetime = "300";
	$counter->connect_to_db();
	$counter->insert_new_hit();
	/*echo "Hits: ";
	echo $counter->show_counter("hits");
	echo "<br />Counter: ";
	echo $counter->show_counter("total");
	echo "<br />Online: ";
	echo $counter->show_counter("online");
	echo "<br />Hits of you (last 24 hours): ";
	echo $counter->show_counter("hits_of_user");*/
	
	$hits = $counter->show_counter("hits");
	for($i = 0; $i < strlen($hits); $i++)
	{
		$img = substr($hits, $i, 1).".gif";
		$str .= "<img src = ".const_Web_Url."themes/".theme."/images/numbers/".$img." align='absmiddle' />";
	}
	
	return $str;
}
///
function getPath($category_id){
	$sql="SELECT parent_id, category_id, category_name".lang." AS category_name, category_brief".lang." AS category_brief FROM ".pre_table."category WHERE category_id='".$category_id."'";
	$rs=recordset($sql);
	$parent_id=$rs['parent_id'];
	
	$child_name = '<a href="'.const_Web_Url.'index.php/menu/'.$rs['category_id'].'/'.codau2kodau($rs['category_name']).'.html'.'" class="path">'.$rs['category_name'].'</a>';
	if($parent_id!=0){
		$sql3="SELECT category_id, category_name".lang." AS category_name FROM category WHERE category_id='".$parent_id."'";
		$rs3=recordset($sql3);
		$parent_name= ' &raquo; <a href="'.const_Web_Url.'index.php/menu/'.$rs3['category_id'].'/'.codau2kodau($rs3['category_name']).'.html'.'" class="path">'.$rs3['category_name'].'</a>';		
	}
	
	$path = "<h3 class='path'><a href='".const_Web_Url."index.php/thuc-don.html' class='path'>".Ourmenu."</a> ".$parent_name." &raquo; ".$child_name."</h3>".$rs['category_brief']."";

	return $path;
}

?>